﻿package system;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import com.hitrust.gs.lib.GSAutoAuditongDateConfigurator;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;

import framework.core.*;
import system.base.*;
import system.data.ProductTypeManagerBase;

public class SelectManager extends SelectBase {

    public final static String SELECT_ALL = "--全部--";
    public final static String SELECT_ALL_VALUE = "";
    public final static String SELECT_PRIX_VALUE = "--";

    public static String viewYesOrNo(String val) throws Exception {
        try {
            if (val.equals(ConstDefine.STR_YES)) {
                return ConstDefine.STR_NAME_YES;
            } else {
                return ConstDefine.STR_NAME_NO;
            }
        } catch (Exception e) {
            return ConstDefine.STR_NAME_NO;
        }
    }

    public static String viewYesOrNoRadio(String radioName, String currVal, String custom) throws Exception {
        String retVal = "";
        retVal = "<input type=radio name='" + radioName + "' value='1' " + (currVal.length() == 0 || "1".equals(currVal) ? " checked " : " ") + custom + "> 是";
        retVal += "<input type=radio name='" + radioName + "' value='0'" + (currVal.length() != 0 && !"1".equals(currVal) ? " checked " : " ") + custom + "> 否";
        return retVal;
    }

    public static String viewYesOrNoSelect(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom,
            String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_YES, ConstDefine.STR_NAME_YES));
        options.add(new SelectOption(ConstDefine.STR_NO, ConstDefine.STR_NAME_NO));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    public static String viewYesOrNoSelect1(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom,
            String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_YES, ConstDefine.STR_NAME_DEAL));
        options.add(new SelectOption(ConstDefine.STR_NO, ConstDefine.STR_NAME_HAND));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    // add by chengbiao.he start
    public static String viewYesOrNoSelectDEALorHAND(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom,
            String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_VAL_DEAL, ConstDefine.STR_NAME_DEAL));
        options.add(new SelectOption(ConstDefine.STR_VAL_HAND, ConstDefine.STR_NAME_HAND));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    public static String viewAuditing(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom,
            String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.AUDITING_MODIFY, ConstDefine.AUDITING_MODIFY_NAME));
        options.add(new SelectOption(ConstDefine.AUDITING_NO, ConstDefine.AUDITING_NO_NAME));
        options.add(new SelectOption(ConstDefine.AUDITING_NOT, ConstDefine.AUDITING_NOT_NAME));
        options.add(new SelectOption(ConstDefine.AUDITING_YES, ConstDefine.AUDITING_YES_NAME));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }
    
    public static String viewYKorMD(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom)
            throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_YK, ConstDefine.STR_NAME_YK));
        options.add(new SelectOption(ConstDefine.STR_MD, ConstDefine.STR_NAME_MD));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    public static String viewDownOrLoad(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom)
            throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ServerDownupfileInfo.DOWNLOADTYPE_UP, ServerDownupfileInfo.DOWNLOADTYPE_UP));
        options.add(new SelectOption(ServerDownupfileInfo.DOWNLOADTYPE_DOWN, ServerDownupfileInfo.DOWNLOADTYPE_DOWN));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    public static String viewUpdownState(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom)
            throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ServerDownupfileInfo.UPLOAD_STATE_SUCCESS, ServerDownupfileInfo.UPLOAD_STATE_SUCCESS));
        options.add(new SelectOption(ServerDownupfileInfo.UPLOAD_STATE_FAIL, ServerDownupfileInfo.UPLOAD_STATE_FAIL));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    public static String viewParmstype(

    String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ServerDownupfileInfo.UPLOAD_PARMSTYPE_TEXT, ServerDownupfileInfo.UPLOAD_PARMSTYPE_TEXT));
        //options.add(new SelectOption(ConstDefine.STR_NO,ServerDownupfileInfo.UPLOAD_STATE_FAIL));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    //add by chengbiao.he end 
    /*
    //获取当前仓库及下级仓库   
    public static String viewWarehouseSelect(DBConnection con, String currWareCode, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom) throws Exception {
        ObjectList list = Warehouse.fetchAllOrgs(con, currWareCode);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            Warehouse c = (Warehouse) list.get(i);
            options.add(new SelectOption("" + c.getCode(), getDiffNum(currWareCode, c.getCode()) + c.viewName(con) + "(" + c.viewCode(con) + ")"));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }*/
    
    
	
    public static String viewWarehouseOfCompanySelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom) throws Exception {
        ObjectList list = Warehouse.fetchAllWarehouseCodeOfCompany(con);
        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            Warehouse c = (Warehouse) list.get(i);
            String code = c.getCode();
            String name = c.getName();
            SelectOption so = new SelectOption(code,name);
            options.add(so);
        }
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    /** 获得当前仓库及其下属仓库    (用于修改后的仓库关系逻辑) add by zhengbin*/	
    public static String viewWarehouseSelect(DBConnection con, String currWareCode, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom) throws Exception {
        ObjectList list = Warehouse.fetchWarehouses(con, currWareCode);
        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            Warehouse c = (Warehouse) list.get(i);
            String name = c.getCode();
            String value = getWarehouseName(currWareCode, c.getCode(), c.getName() + "("+c.getCode()+")"); 
            SelectOption so = new SelectOption(name,value);
            options.add(so);
        }
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    
    /** 获得当前仓库及其下属仓库    (用于修改后的仓库关系逻辑) add by zhengbin*/	
    public static String viewWarehouseSelectList(DBConnection con, String currWareCode, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom) throws Exception {
        ObjectList list = Warehouse.fetchWarehousesList(con, currWareCode);
        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            Warehouse c = (Warehouse) list.get(i);
            String name = c.getCode();
            String value = getWarehouseName(currWareCode, c.getCode(), c.getName() + "("+c.getCode()+")"); 
            SelectOption so = new SelectOption(name,value);
            options.add(so);
        }
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    
    /** 设计出 具有等级标志的 仓库名称列表*/
    private static String getWarehouseName(String currentTopCode,String currentCode,String currentName){
        int level = calculateWarehouseCode(currentTopCode, currentCode);
        String warehouseName = loopWarehouseName(level, currentName);
        return warehouseName;
    }
    
    /** 计算  仓库编码    级别*/
    private static int calculateWarehouseCode(String currentTopCode,String currentCode){
        int topLen = currentTopCode.length();
        int currentLen = currentCode.length();
        int level = currentLen - topLen;
        level = level/2;
        return level;
    }
    
    /** 循环 根据仓库编码级别 形成带特殊符号的仓库名称*/
    private static String loopWarehouseName(int level,String warehouseName){
        String label = "";
        for (int i = 0; i < level; i++) {
            label += SELECT_PRIX_VALUE;
        }
        label += warehouseName;
        return label;
    }
    
    
    /**     */
    public static String viewWarehouseStaffSelect(DBConnection con, String currWareCode, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom, String[] warehouseCodes) throws Exception {
        DBResult result = null;
        Vector vec = new Vector();
        try {
            /** 这段代码可按仓库执行查询*/
            String sql = "select id,name from t_warehouse_staff where warehouse_code in(";
            String sql1 ="";
            for (int i = 0; i < warehouseCodes.length; i++) {
                if (warehouseCodes.length == 1) {
                    sql += "'" + warehouseCodes[i] + "'";
                    sql += ")";
                } else if (i == warehouseCodes.length - 1) {
                    sql += "'" + warehouseCodes[i] + "'";
                    sql += ")";
                } else {
                    sql += "'" + warehouseCodes[i] + "',";
                }
                if(warehouseCodes[i].equals("000000")){
                    sql = "select id,name from t_warehouse_staff";
                    break;
                }
                GSAutoAuditongDateConfigurator.getInstance();
                String noshareWarehouseCode = warehouseCodes[i].substring(0, warehouseCodes[i].length()-2);
                if(GSAutoAuditongDateConfigurator.isShareDatesWarehouses(noshareWarehouseCode)){
                	if(!GSAutoAuditongDateConfigurator.isNoShareWarehouseProductDatesWarehouses(noshareWarehouseCode)){
                		sql1+=" or warehouse_code like '"+noshareWarehouseCode+"%'";
                	}  	
                }
            }
            //String sql = "select id,name from t_warehouse_staff order by name";
            /** 这段代码可按仓库执行查询*/
            result = DBEngine.doSelect(con, sql+sql1);
            java.sql.ResultSet rs = result.getRs();
            while (rs.next()) {
                WarehouseStaff obj = new WarehouseStaff();
                obj.setId(rs.getString(1));
                obj.setName(rs.getString(2));
                vec.add(obj);
            }
        }catch(NullPointerException e){
            
        } finally {
            if (result != null)
                result.clear();
        }
        ArrayList options = new ArrayList();
        options.add(new SelectOption("", "---全部---"));
        for (int i = 0; i < vec.size(); i++) {
            WarehouseStaff c = (WarehouseStaff) vec.get(i);
            options.add(new SelectOption(c.getId(), c.getName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    /**
     * 获取货位
     * @param con
     * @param currWareCode
     * @param selectName
     * @param currVal
     * @param needAll
     * @param allValue
     * @param allDisplay
     * @param allCustom
     * @param custom
     * @param warehouseCodes
     * @return
     * @throws Exception
     */
    public static String viewWarehousePosition(DBConnection con, String currWareCode, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom, String[] warehouseCodes) throws Exception {
        DBResult result = null;
        Vector vec = new Vector();
        try {
            /** 这段代码可按仓库执行查询*/
            String sql = "select code,name from t_position where warehouse_code in(";
            for (int i = 0; i < warehouseCodes.length; i++) {
                if (warehouseCodes.length == 1) {
                    sql += "'" + warehouseCodes[i] + "'";
                    sql += ")";
                } else if (i == warehouseCodes.length - 1) {
                    sql += "'" + warehouseCodes[i] + "'";
                    sql += ")";
                } else {
                    sql += "'" + warehouseCodes[i] + "',";
                }
                if(warehouseCodes[i].equals("000000")){
                    sql = "select code,name from t_position";
                    break;
                }
            }
            //String sql = "select id,name from t_warehouse_staff order by name";
            /** 这段代码可按仓库执行查询*/
            result = DBEngine.doSelect(con, sql);
            java.sql.ResultSet rs = result.getRs();
            while (rs.next()) {
                WarehouseStaff obj = new WarehouseStaff();
                obj.setId(rs.getString(1));
                obj.setName(rs.getString(2));
                vec.add(obj);
            }
        }catch(NullPointerException e){
 
        } finally {
            if (result != null)
                result.clear();
        }
        ArrayList options = new ArrayList();
        options.add(new SelectOption("", "---全部---"));
        for (int i = 0; i < vec.size(); i++) {
            WarehouseStaff c = (WarehouseStaff) vec.get(i);
            options.add(new SelectOption(c.getId(), c.getName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    public static String viewPosition(DBConnection con, String currWareCode, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom, String[] warehouseCodes) throws Exception {
        DBResult result = null;
        Vector vec = new Vector();
        try {
            /** 这段代码可按仓库执行查询*/
            String sql = "select code,name from t_position where warehouse_code like ";
            for (int i = 0; i < warehouseCodes.length; i++) {
                if (warehouseCodes.length == 1) {
                    sql += "'" + warehouseCodes[i] + "%'";
                }
            }
            //String sql = "select id,name from t_warehouse_staff order by name";
            /** 这段代码可按仓库执行查询*/
            result = DBEngine.doSelect(con, sql);
            java.sql.ResultSet rs = result.getRs();
            while (rs.next()) {
                WarehouseStaff obj = new WarehouseStaff();
                obj.setId(rs.getString(1));
                obj.setName(rs.getString(2));
                vec.add(obj);
            }
        }catch(NullPointerException e){
 
        } finally {
            if (result != null)
                result.clear();
        }
        ArrayList options = new ArrayList();
        options.add(new SelectOption("", "---全部---"));
        for (int i = 0; i < vec.size(); i++) {
            WarehouseStaff c = (WarehouseStaff) vec.get(i);
            options.add(new SelectOption(c.getId(), c.getName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    private static String getDiffNum(String topWareCode, String currWareCode) {
        int number = getNum(topWareCode) - getNum(currWareCode);
        String rtn = "";
        for (int i = 0; i < number; i++) {
            rtn += SELECT_PRIX_VALUE;
        }
        return rtn;
    }

    private static int getNum(String currWareCode) {
        int num = 0;
        if (currWareCode != null) {
            String temp = currWareCode.substring(currWareCode.length() - ConstDefine.PRIX.length(), currWareCode.length());
            while (temp.equals(ConstDefine.PRIX) && (currWareCode.length() >= ConstDefine.PRIX.length())) {
                try {
                    currWareCode = currWareCode.substring(0, currWareCode.length() - ConstDefine.PRIX.length());
                    temp = currWareCode.substring(currWareCode.length() - ConstDefine.PRIX.length(), currWareCode.length());
                    num++;
                } catch (Exception e) {
                }
            }
        }
        return num;
    }

    //add by wing start
    public static String viewValidOrNoSelect(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom,
            String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_YES, ConstDefine.STR_NAME_VALID_YES));
        options.add(new SelectOption(ConstDefine.STR_NO, ConstDefine.STR_NAME_VALID_NO));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    public static String viewValidOrNo(String val) throws Exception {
        try {
            if (val.equals(ConstDefine.STR_YES)) {
                return ConstDefine.STR_NAME_VALID_YES;
            } else {
                return ConstDefine.STR_NAME_VALID_NO;
            }
        } catch (Exception e) {
            return ConstDefine.STR_NAME_VALID_NO;
        }
    }

    public static String viewValidOrNoRadio(String radioName, String currVal, String custom) throws Exception {
        String retVal = "";
        retVal = "<input type=radio name='" + radioName + "' value='1' " + (currVal.length() == 0 || "1".equals(currVal) ? " checked " : " ") + custom + "> 有效";
        retVal += "<input type=radio name='" + radioName + "' value='0'" + (currVal.length() != 0 && !"1".equals(currVal) ? " checked " : " ") + custom
                + "> 无效";
        return retVal;
    }

    public static String viewYesOrNo1(String val) throws Exception {
        try {
            if (val.equals(ConstDefine.STR_YES)) {
                return ConstDefine.STR_NAME_DEAL;
            } else {
                return ConstDefine.STR_NAME_HAND;
            }
        } catch (Exception e) {
            return ConstDefine.STR_NAME_HAND;
        }
    }

    public static String viewYesOrNoRadio1(String radioName, String currVal, String custom) throws Exception {
        String retVal = "";
        retVal = "<input type=radio name='" + radioName + "' value='1' " + (currVal.length() == 0 || "1".equals(currVal) ? " checked " : " ") + custom
                + "> 交易平台导入";
        retVal += "<input type=radio name='" + radioName + "' value='0'" + (currVal.length() != 0 && !"1".equals(currVal) ? " checked " : " ") + custom
                + "> 手工录入";
        return retVal;
    }

    public static String viewFOrM(String val) throws Exception {
        try {
            if (val.equals(ConstDefine.STR_YES)) {
                return ConstDefine.STR_NAME_MALE;
            } else {
                return ConstDefine.STR_NAME_FEMALE;
            }
        } catch (Exception e) {
            return ConstDefine.STR_NAME_FEMALE;
        }
    }

    public static String viewFOrMRadio(String radioName, String currVal, String custom) throws Exception {
        String retVal = "";
        retVal = "<input type=radio name='" + radioName + "' value='1' " + (currVal.length() == 0 || "1".equals(currVal) ? " checked " : " ") + custom + "> 男";
        retVal += "<input type=radio name='" + radioName + "' value='0'" + (currVal.length() != 0 && !"1".equals(currVal) ? " checked " : " ") + custom + "> 女";
        return retVal;
    }

    public static String viewDullStorageSelect(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom,
            String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.DULL_STORAGE_TIME_60, ConstDefine.DULL_STORAGE_TIME_60_NAME));
        options.add(new SelectOption(ConstDefine.DULL_STORAGE_TIME_90, ConstDefine.DULL_STORAGE_TIME_90_NAME));
        options.add(new SelectOption(ConstDefine.DULL_STORAGE_TIME_180, ConstDefine.DULL_STORAGE_TIME_180_NAME));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    public static String viewYesOrNoBalance(String val) throws Exception {
        try {
            if (val.equals(ConstDefine.STR_YES)) {
                return ConstDefine.STR_NAME_BALANCE_YES;
            } else {
                return ConstDefine.STR_NAME_BALANCE_NO;
            }
        } catch (Exception e) {
            return ConstDefine.STR_NAME_BALANCE_NO;
        }
    }

    public static String viewBalanceModel(String val) throws Exception {
        try {
            if (val.equals(ConstDefine.STR_YK)) {
                return ConstDefine.STR_NAME_YK;
            } else {
                return ConstDefine.STR_NAME_MD;
            }
        } catch (Exception e) {
            return ConstDefine.STR_NAME_MD;
        }
    }
    
    public static Provider ProvideName(DBConnection con,String code)throws Exception
    {
        Provider obj = new Provider();
        obj = Provider.fetchByCode(con, code);
        return obj;
    }

    public static String viewBalanceOrNoSelect(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom,
            String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_NO, ConstDefine.STR_NAME_BALANCE_NO));
        options.add(new SelectOption(ConstDefine.STR_YES, ConstDefine.STR_NAME_BALANCE_YES));
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    //取“出入库类型”表中的所有入库类型   
    public static String viewInTypeSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        InoutTypeSearchEvent inoutEvent = new InoutTypeSearchEvent();
        inoutEvent.setInoutType(ConstDefine.STR_IN);
        inoutEvent.setOrderField(InoutType.DISPLAY_ORDER);
        inoutEvent.setOrderDesc(true);
        ObjectList list = InoutType.fetch().search(con, inoutEvent.toConditions());

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            InoutType c = (InoutType) list.get(i);
            options.add(new SelectOption(c.getCode(), c.viewName(con)));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    //取“出入库类型”表中的所有出库类型   
    public static String viewOutTypeSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        InoutTypeSearchEvent inoutEvent = new InoutTypeSearchEvent();
        inoutEvent.setInoutType(ConstDefine.STR_OUT);
        inoutEvent.setOrderField(InoutType.DISPLAY_ORDER);
        inoutEvent.setOrderDesc(true);
        ObjectList list = InoutType.fetch().search(con, inoutEvent.toConditions());

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            InoutType c = (InoutType) list.get(i);
            options.add(new SelectOption(c.getCode(), c.viewName(con)));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    //获取系统内所有有效客户   
    public static String viewCustomerSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ObjectList list = Customer.fetchAllOrgs(con);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            Customer c = (Customer) list.get(i);
            options.add(new SelectOption("" + c.getCode(), getDiffNum(c.getCode()) + c.viewName(con) + "(" + c.viewCode(con) + ")"));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    public static String getDiffNum(String currCode) {
        int number = currCode.length() / Customer.PRIX.length() - 1;
        String rtn = "";
        for (int i = 0; i < number; i++) {
            rtn += SELECT_PRIX_VALUE;
        }
        return rtn;
    }

    //add by wing end

    //add by Sindy start

    public static String viewGrandFatherSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ObjectList list = ProductCategory.fetchNo1Category(con);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            ProductCategory c = (ProductCategory) list.get(i);
            options.add(new SelectOption("" + c.getCode(), c.getName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    
    public static String viewProviderListSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        List list = ProductType.getProviderList(con,"");

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
        	ProductType c = (ProductType) list.get(i);
            options.add(new SelectOption("" + c.getProviderCode(), c.getRemark()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    
    public static String viewProductTypeListSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ObjectList list = ProductTypeManager.getProductTypeList(con);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
        	ProductTypeManager c = (ProductTypeManager) list.get(i);
            options.add(new SelectOption("" + c.getProductType(), c.getTypeName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    
    public static String viewBidTypeListSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ObjectList list = ProductTypeManager.getBidTypeList(con);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
        	ProductTypeManager c = (ProductTypeManager) list.get(i);
            options.add(new SelectOption("" + c.getProductType(), c.getTypeName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    
    public static String viewUpperProductTypeSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ObjectList list = ProductTypeManager.getUpperProductType(con);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            ProductTypeManagerBase c = (ProductTypeManagerBase) list.get(i);
            options.add(new SelectOption("" + c.getProductType(), c.getTypeName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    
    public static String viewProductTypeSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ObjectList list = ProductTypeManager.getProductType(con);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            ProductTypeManagerBase c = (ProductTypeManagerBase) list.get(i);
            options.add(new SelectOption("" + c.getProductType(), c.getTypeName()));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    public static String viewUpperSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    public static String viewIsTradeflatCategorySelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_VAL_DEAL, ConstDefine.STR_NAME_DEAL));
        options.add(new SelectOption(ConstDefine.STR_VAL_HAND, ConstDefine.STR_NAME_HAND));

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    public static String viewInoutTypeSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();
        options.add(new SelectOption(ConstDefine.STR_IN, ConstDefine.STR_NAME_IN));
        options.add(new SelectOption(ConstDefine.STR_OUT, ConstDefine.STR_NAME_OUT));

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    //add by Sindy end

    // add by Jackey start
    public static String[][] getYears() {
        String[][] tStr = new String[15][2];
//        tStr[0][0] = "2005";
//        tStr[1][0] = "2006";
//        tStr[2][0] = "2007";
//        tStr[3][0] = "2008";
//        tStr[0][0] = "2009";
        tStr[0][0] = "2010";
        tStr[1][0] = "2011";
        tStr[2][0] = "2012";
        tStr[3][0] = "2013";
        tStr[4][0] = "2014";
        tStr[5][0] = "2015";
        tStr[6][0] = "2016";
        tStr[7][0] = "2017";
        tStr[8][0] = "2018";
        tStr[9][0] = "2019";
        tStr[10][0] = "2020";
        tStr[11][0] = "2021";
        tStr[12][0] = "2022";
        tStr[13][0] = "2023";
        tStr[14][0] = "2024";

//        tStr[0][1] = "2005年";
//        tStr[1][1] = "2006年";
//        tStr[2][1] = "2007年";
//        tStr[3][1] = "2008年";
//        tStr[0][1] = "2009年";
        tStr[0][1] = "2010年";
        tStr[1][1] = "2011年";
        tStr[2][1] = "2012年";
        tStr[3][1] = "2013年";
        tStr[4][1] = "2014年";
        tStr[5][1] = "2015年";
        tStr[6][1] = "2016年";
        tStr[7][1] = "2017年";
        tStr[8][1] = "2018年";
        tStr[9][1] = "2019年";
        tStr[10][1] = "2020年";
        tStr[11][1] = "2021年";
        tStr[12][1] = "2022年";
        tStr[13][1] = "2023年";
        tStr[14][1] = "2024年";
        return tStr;
    }
    
    public static String[][] getYearsHis() {
        String[][] tStr = new String[3][2];
//        tStr[0][0] = "2005";
//        tStr[1][0] = "2006";
//        tStr[2][0] = "2007";
        tStr[0][0] = "2008";
        tStr[1][0] = "2009";
        tStr[2][0] = "2010";
        tStr[0][1] = "2008年";
        tStr[1][1] = "2009年";
        tStr[2][1] = "2010年";
        return tStr;
    }
    
    public static String viewYearSelectHis(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        String[][] listYears = getYearsHis();

        ArrayList options = new ArrayList();
        for (int i = 0; i < listYears.length; i++) {
            String[] strYear = listYears[i];
            options.add(new SelectOption("" + strYear[0], strYear[1]));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    public static String viewYearSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        String[][] listYears = getYears();

        ArrayList options = new ArrayList();
        for (int i = 0; i < listYears.length; i++) {
            String[] strYear = listYears[i];
            options.add(new SelectOption("" + strYear[0], strYear[1]));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    public static String[][] getMonths() {
        String[][] tStr = new String[12][2];
        tStr[0][0] = "01";
        tStr[1][0] = "02";
        tStr[2][0] = "03";
        tStr[3][0] = "04";
        tStr[4][0] = "05";
        tStr[5][0] = "06";
        tStr[6][0] = "07";
        tStr[7][0] = "08";
        tStr[8][0] = "09";
        tStr[9][0] = "10";
        tStr[10][0] = "11";
        tStr[11][0] = "12";

        tStr[0][1] = "1月";
        tStr[1][1] = "2月";
        tStr[2][1] = "3月";
        tStr[3][1] = "4月";
        tStr[4][1] = "5月";
        tStr[5][1] = "6月";
        tStr[6][1] = "7月";
        tStr[7][1] = "8月";
        tStr[8][1] = "9月";
        tStr[9][1] = "10月";
        tStr[10][1] = "11月";
        tStr[11][1] = "12月";

        return tStr;
    }

    public static String viewMonthSelect(DBConnection con, String selectName, String currVal, boolean needAll, String allValue, String allDisplay,
            String allCustom, String custom) throws Exception {
        String[][] listMonths = getMonths();

        ArrayList options = new ArrayList();
        for (int i = 0; i < listMonths.length; i++) {
            String[] strMonth = listMonths[i];
            options.add(new SelectOption("" + strMonth[0], strMonth[1]));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }

    // add by Jackey end

    //add by Sindy start
    //获取当前客户及下级客户   
    public static String viewCustomerSelect(DBConnection con, String currWarehouseCode, String selectName, String currVal, boolean needAll, String allValue,
            String allDisplay, String allCustom, String custom) throws Exception {
        ObjectList list = Customer.fetchAllOrgs(con, "", currWarehouseCode);

        ArrayList options = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            Customer c = (Customer) list.get(i);
            //options.add(new SelectOption("" + c.getCode(), getDiffNum(currCusCode,c.getCode())+c.viewName(con)+"("+c.viewCode(con)+")"));
            options.add(new SelectOption("" + c.getCode(), getDiffNum(c.getCode()) + c.viewName(con) + "(" + c.viewCode(con) + ")"));
        }

        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, allCustom, custom);
    }
    //add by Sindy end
    
    //add by Arrow start
    public static String viewWorldExpBillType(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();
        Map map = ConstDefine.initWorldExpCode();
        for(int i = 0; i < ConstDefine.BILL_TYPE_CODE.length; i++){
            options.add(new SelectOption(ConstDefine.BILL_TYPE_CODE[i], (String)map.get(ConstDefine.BILL_TYPE_CODE[i])));
        }
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }
    
    public static String viewWorldExpBusType(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();
        for(int i = 0; i < ConstDefine.BUS_TYPE.length; i++){
            options.add(new SelectOption(ConstDefine.BUS_TYPE[i], ConstDefine.BUS_TYPE[i]));
        }
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }
    
    public static String viewWarehouseJTCode(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom, String warehouseCode) throws Exception {
        ArrayList options = new ArrayList();
        String warehouseJTCode = WorldExp.changeWarehouseJTCode(warehouseCode);
        
        Map map = ConstDefine.initWorldExpWarehouse();
        if("00".equals(warehouseJTCode)){
            for(int i = 0; i < ConstDefine.WAREHOUSE_JT_CODE.length; i++){
                options.add(new SelectOption(ConstDefine.WAREHOUSE_JT_CODE[i], (String)map.get(ConstDefine.WAREHOUSE_JT_CODE[i])));
            }
            return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
        }
        else{
            options.add(new SelectOption(warehouseJTCode, (String)map.get(warehouseJTCode)));
        }
        //options.add(new SelectOption(ConstDefine.STR_YK, ConstDefine.STR_NAME_YK));
        //options.add(new SelectOption(ConstDefine.STR_MD, ConstDefine.STR_NAME_MD));
        return viewSelect(options, selectName, currVal, false, allValue, allDisplay, null, custom);
    }
    
    public static String viewInputMoneyType(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();
        for(int i = 0; i < ConstDefine.ZCJType.length; i++){
            options.add(new SelectOption(ConstDefine.ZCJType[i], ConstDefine.ZCJType[i]));
        }
        
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }
    
    public static String viewOtherMoneyType(String selectName, String currVal, boolean needAll, String allValue, String allDisplay, String allCustom, String custom) throws Exception {
        ArrayList options = new ArrayList();
        
        for(int i = 0; i < ConstDefine.OtherMoneyType.length; i++){
            options.add(new SelectOption(ConstDefine.OtherMoneyType[i], ConstDefine.OtherMoneyType[i]));
        }
        
        return viewSelect(options, selectName, currVal, needAll, allValue, allDisplay, null, custom);
    }

    //public static 
    //add by Arrow end
}
